{% extends 'accounts/auth_base.html' %}

{% load form_extras %}

{% block title %}用户注册{% endblock %}

{% block content %}
<div class="row justify-content-center position-relative flex-grow-1" style="z-index: 1;">
    <div class="col-12 d-flex align-items-center">
        <div class="card border-0 shadow-lg w-100" style="border-radius: 25px; overflow: hidden; background-color: rgba(255, 255, 255, 0.85);">
            <div class="card-body px-5 py-4">
                <div class="text-center mb-4">
                    <div class="mb-3">
                        <div class="bg-gradient-primary rounded-circle mx-auto d-flex align-items-center justify-content-center" 
                             style="width: 90px; height: 90px; box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);">
                            <i class="fas fa-user-plus text-white" style="font-size: 2.8rem;"></i>
                        </div>
                    </div>
                    <h2 class="h3 fw-bold text-dark mb-2">创建账户</h2>
                    <p class="text-muted mb-4">填写信息注册新账户</p>
                </div>
                
                <form method="post" class="text-start">
                    {% csrf_token %}
                    
                    {% if form.non_field_errors %}
                        <div class="alert alert-danger alert-dismissible fade show rounded-pill px-4 py-3 mb-4 shadow-sm" role="alert">
                            <i class="fas fa-exclamation-circle me-2"></i>{{ form.non_field_errors }}
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    {% endif %}
                    
                    <div class="row">
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.username.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-user me-2 text-primary"></i>用户名
                            </label>
                            {{ form.username|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.username.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.username.errors }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.nickname.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-signature me-2 text-primary"></i>昵称
                            </label>
                            {{ form.nickname|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.nickname.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.nickname.errors }}</div>
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.email.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-envelope me-2 text-primary"></i>邮箱
                            </label>
                            {{ form.email|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.email.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.email.errors }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.phone.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-phone me-2 text-primary"></i>电话
                            </label>
                            {{ form.phone|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.phone.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.phone.errors }}</div>
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.password1.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-lock me-2 text-primary"></i>密码
                            </label>
                            {{ form.password1|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.password1.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.password1.errors }}</div>
                            {% endif %}
                            <div class="form-text ms-2 mt-2 text-muted">密码长度至少8位</div>
                        </div>
                        
                        <div class="col-md-6 mb-4">
                            <label for="{{ form.password2.id_for_label }}" class="form-label fw-semibold text-dark mb-2">
                                <i class="fas fa-lock me-2 text-primary"></i>确认密码
                            </label>
                            {{ form.password2|add_class:"form-control form-control-lg border-0 py-3 shadow-sm" }}
                            {% if form.password2.errors %}
                                <div class="text-danger mt-2 rounded-pill px-3 py-2 bg-danger bg-opacity-10">{{ form.password2.errors }}</div>
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="d-grid mt-4">
                        <button type="submit" 
                                class="btn btn-primary btn-lg py-3 rounded-pill fw-semibold shadow-lg" 
                                style="letter-spacing: 1px; transition: all 0.3s;">
                            <i class="fas fa-user-plus me-2"></i>注册
                        </button>
                    </div>
                </form>
            </div>
            
            <div class="card-footer border-0 text-center py-4">
                <p class="mb-0 text-muted">
                    已有账户? 
                    <a href="{% url 'accounts:login' %}" class="text-decoration-none fw-bold text-primary">
                        立即登录
                    </a>
                </p>
            </div>
        </div>
    </div>
</div>
<div class="row justify-content-center">
    <div class="col-12 text-center mb-4">
        <p class="text-white mb-0" style="text-shadow: 0 2px 4px rgba(0,0,0,0.1); font-weight: 500;">
            &copy; 2025 RBAC权限管理系统
        </p>
    </div>
</div>
{% endblock %}